<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>制卡数据生成</title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<script src="${pageContext.request.contextPath }/scripts/boot.js" type="text/javascript"></script>
			<style type="text/css">
				html,body {
				    margin: 0;
				    padding: 0;
				    border: 0;
				    width: 100%;
				    height: 100%;
				    overflow: hidden;
				}
			</style>
	</head>
    <body>
     <!-- ============================== 第一部分 查询条件================================================== -->
		<form id="form1" method="post">
			  <div style="padding-bottom:5px;">
			    <table style="border:solid 1px #aaa;width:100%;">
			  	    <tr style="width:100%;">
						<td style="width:15%;text-align:right;">制卡批次:</td>
						<td style="width:25%;">
							<input id="aaz001" name="aaz001" class="mini-textbox" required="true" emptyText="请输入10位制卡批次，以GR或DW开始..." style="width:100%;"  maxLength="10"/>
						</td>
						<td style="width:15%;text-align:right;">银行:</td>
						<td style="width:30%;">
							<input id="aae008" name="aae008" class="mini-combobox" valueField="aaa102"  required="true"
				                   textField="aaa103" emptyText="请选择银行..."
				                   url="${pageContext.request.contextPath }/AZ20.do?method=getselect&AAA100=bank" style="width:100%;" />
			            </td>
						 <td style="width:10%;text-align: left; white-space:nowrap;">
			          		<a class="mini-button" iconCls="icon-search" onclick="search()">查询</a>
			          		<a class="mini-button" onclick="onReset()"    iconCls="icon-remove">重置</a>
			        	</td>
					</tr>
				   </table>
			  </div>
		
	 <!-- ============================== 第二部分 查询结果================================================== -->
		
		<div style="width:100%;">
		  <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
		    <table style="width:100%;">
		      <tr>
		        <td style="width:100%;">
		         &nbsp;
		        </td>
		      </tr>
		    </table>
		  </div>
		</div>
		<div>
		  <div id="datagrid1" class="mini-datagrid" style="width:100%;height:350px;" allowResize="true" frozenStartColumn="0" frozenEndColumn="2"
		       url="${pageContext.request.contextPath}/AZ20.do?method=getAZ20" idField="id" multiSelect="true" >
		    <div property="columns">
		      <div field="aab001" width="150" headerAlign="center" align="center" >劳动保障证号</div>
		      <div field="aac001" width="150" headerAlign="center" align="center" >社会保障卡号</div>
		      <div field="aac003" width="80" headerAlign="center" align="center" >姓名</div>
		      <div field="aac004" width="100" headerAlign="center" align="center" >性别</div>
		      <div field="aac002" width="160" headerAlign="center" align="center" >证件号</div>
		      <div field="aac005" width="100" headerAlign="center" align="center" >民族</div>
		      <div field="aaz501" width="160" headerAlign="center" align="center" >卡识别号</div>
		      <div field="caz002" width="160" headerAlign="center" align="center" >通卡卡面号</div>
		      <div field="aae008" width="120" headerAlign="center" align="center" >制卡银行</div>
		       </div>
		  </div>
		</div>
	 <!-- ============================== 第三部分 按钮================================================== -->
		<br/>
	    <div>
	    	<table style="table-layout:fixed;width:100%;" cellpadding="0" cellspacing="10">
	    		<tr>
			     <td style="width:80px;white-space:nowrap;text-align: center"><a class="mini-button" onclick="onOk" name="onScsj" enabled="false" style="width:100px" iconCls="icon-ok">生成制卡数据</a>
			     </td>
	    		</tr>
	    	</table>
	    </div> 
	</form>	
		
<script type="text/javascript">
    mini.parse();
    var grid = mini.get("datagrid1");
    var form = new mini.Form("form1");
    grid.load();
    
    function search() {
	      var aaz001 = mini.getbyName("aaz001").getValue().trim();
	      var aae008 = mini.getbyName("aae008").getValue().trim();
	      var flag = aaz001.substring(0,2);
	      var len = aaz001.length;
	      if (aaz001 == "" && aae008 == "") {
		         mini.alert("请输入查询条件");
		         return;
		  } 
	      if(flag != 'GR' && flag != 'DW'){
      		mini.alert("请输入以GR或者DW开头的十位制卡批次！")
      		return ;
   		 }
   		 if(len != 10){
			mini.alert("请输入以GR或者DW开头的十位制卡批次！")
			return ;
		 }
	      if (aaz001 == "" && aae008 != "") {
	         mini.alert("请输入制卡批次");
	         return;
	      } 
	      if (aaz001 != "" && aae008 == "") {
		         mini.alert("请输入银行");
		         return;
		  } 
	      grid.load({ aaz001: aaz001, aae008: aae008});
	      mini.getbyName("onScsj").setEnabled(true);
	      mini.getbyName("aaz001").setAllowInput(false);
	 } 
	  function onOk(e){
   		var data = grid.getData();
   		if(data == "") {
   		   mini.alert("没有查询出相应的数据，无法进行数据生成");
   		   return;
   		} 
	  	SavaData();
	  }
	  
	  function SavaData(){
	    var aaz001 = mini.getbyName("aaz001").getValue().trim();
	    var aae008 = mini.getbyName("aae008").getValue().trim();
        var o = form.getData();
        form.validate();
        if (form.isValid() == false) 
        		return;
        if(form.isValid()==true){
       		mini.mask({el: document.body,cls: 'mini-mask-loading',html: '生成中...'});
            var json = mini.encode([o]);
            $.ajax({
                  url: "${pageContext.request.contextPath}/AZ20.do?method=saveAZ20",
                  type: 'post',
                  data: { data: json},
                  cache: false,       
                  success: function (text) {
                	mini.unmask(); 
                  	mini.alert(text);
                  	grid.load({ aaz001: aaz001, aae008: aae008});
                  },
                  error: function (jqXHR, textStatus, errorThrown) {
                    alert(jqXHR.responseText);
                    CloseWindow();
                  }
              });
          }
        	
        }
        
        function onReset(e) {
			form.clear();	
			grid.load();
			mini.getbyName("onScsj").setEnabled(false);
	        mini.getbyName("aaz001").setAllowInput(true);
		}		
</script>
</body>
</html>
